var AddPayerModel = function() {
	this.addPayerForm = $("#addPayerForm");
	this.savePayer = $("#savePayer");
};

var AddPayer = function(model) {
	var validator = new AddPayerValidator(model);
	
	this.init = function() {
		validator.validate();
	};
};

var AddPayerValidator = function(model){
	
	this.validate = function() {
		return model.addPayerForm.validate({
			rules : {
				firstname : {
					required : true,
					minlength : 2,
					maxlength : 100
					},
				lastname : {
					required : true,
					minlength : 2,
					maxlength : 100
					},
				email : {
					required : true,
					email : true
				},
				password : {
					required : true,
					minlength: 4
				},
				re_password : {
					minlength: 4,
					equalTo: "#password"
				}
			},
			messages : {
				firstname : {
					required : "Firstname is required field and should be filled in.",
					minlength : "Firstname should be more than 2 symbols.",
					maxlength : "Firstname should be less than 100 symbols."
				},
				lastname : {
					required : "Lastname is required field and should be filled in.",
					minlength : "Lastname should be more than 2 symbols.",
					maxlength : "Lastname should be less than 100 symbols."
				},
				email : {
					required: "Email is required field and should be filled in.",
				    email: "Your email address must be in the format of name@domain.com"
				},
				password : {
					required : "Password is required field and should be filled in."
				},
				re_password : {
					equalTo : "Entered passwords are mismatch."
				}
			}
		});
	};
};